<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="list" lay-title="充值记录">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card hxr-layui-card" id="memberlistv">
                    <div class="layui-form hxradmin-card-header">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">会员姓名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="user" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <!-- <div class="layui-inline">
                                <label class="layui-form-label">支付方式</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="type" autocomplete="off" class="layui-input">
                                </div>
                            </div> -->
                            <div class="layui-inline">
                                <label class="layui-form-label" style='width:85px;'>开始日期范围</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="val2" id='date' autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">支付状态</label>
                                <div class="layui-input-inline">
                                    <div class="layui-unselect layui-form-select">
                                        <div class="layui-select-title"><input name="status" type="text" value="" placeholder="选择支付状态" readonly class="layui-input layui-unselect"><i
                                                class="layui-edge"></i></div>
                                        <dl class="layui-anim layui-anim-upbit" style="">
                                            <dd lay-value="" class="layui-select-tips layui-this">选择状态</dd>
                                            <dd data='2'>已支付</dd>
                                            <dd data='1'>未支付</dd>
                                        </dl>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn" data-type="reload" id="search">搜索</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="list-table" lay-filter="list-table"></table>

                    </div>
                </div>
                <script type="text/html" id="pay_status">
                    {{#  if(d.status === 2){ }}
                    <span class="layui-badge layui-bg-green">已支付</span>
                    {{#  } else if(d.status === 1) { }}
                    <span class="layui-badge">未支付</span>
                    {{#   } }}
                </script>
                <script type="text/html" id="is_calculation">
                    {{#  if(d.is_calculation === 1){ }}
                    <span class="layui-badge layui-bg-green">未结算</span>
                    {{#  } else if(d.is_calculation === 2) { }}
                    <span class="layui-badge">已结算</span>
                    {{#   } else if(d.is_calculation === 3) { }}
                    <span class="layui-badge layui-bg-blue">已作废</span>
                    {{#   } }}
                </script>
            </div>
        </div>
    </div>
</div>
<script>
    var formurl='members/memberform',formarea=['500px', '600px'];
    //表格数据渲染
    layui.use(['table', 'form','laydate'], function() {
        var table = layui.table,
            form = layui.form,
            $ = layui.$,laydate=layui.laydate;
        //日期范围
        laydate.render({
            elem: '#date'
            ,range: true
        });
        layui.admin.initlist(table,'members/charter_list',240,[
            [{
                field: 'charter_id',
                title: 'ID',
                width: 60
            },{
                field: 'real_name',
                title: '会员姓名',
                minwidth: 100
            },{
                field: 'charter_time',
                title: '包机时间（天）',
                width: 100
            },{
                field: 'price_total',
                title: '包机总金额(元)',
                width: 110
            },{
                field: 'balance',
                title: '余额扣款(元)',
                width: 110
            },{
                field: 'credit_amount',
                title: '赠送余额扣款（元）',
                width: 150
            },{
                field: 'cash',
                title: '现金扣款（元）',
                width: 150
            },{
                field: 'status',
                title: '支付状态',
                width: 150,
                templet:'#pay_status'
            },{
                field: 'start_time',
                title: '开始时间',
                width: 180,
            },{
                field: 'end_time',
                title: '结束时间',
                width: 180,

            },{
                field: 'pay_time',
                title: '支付时间',
                width: 200
            },{
                field: 'old_charter',
                title: '说明',
                width: 200
            },{
                field: 'agent_income',
                title: '佣金（元）',
                width: 200
            },{
                field: 'withdraw_proportion',
                title: '佣金比例（%）',
                width: 200
            },{
                field: 'create_time',
                title: '创建时间',
                width: 200
            },{
                field: 'is_calculation',
                title: '状态',
                width: 200,
                templet:'#is_calculation'
            }]
        ])
        //监听表格表单操作
        form.on('switch(list-tableF)', function(obj) {
            var json = JSON.parse(decodeURIComponent($(this).data('json')));
            json = table.clearCacheKey(json);
            // json.member_status == 1 ? json.member_status = 2 : json.member_status = 1;
            layui.admin.ajax('members/update_member', json).then((res) => {
                layui.admin.ahint(res.code,res.msg);
                layui.table.reload('list-table');
            }).catch((res) => {});
        });
        //监听表格操作事件
        table.on('tool(list-table)', function(obj) {
            var data = obj.data;

        });
        $('#search').on('click', function() {
            var val1 = $('input[name="user"]').val(),
                val2 = $('input[name="val2"]').val(),
                type = $('input[name="type"]').val(),
                status = $('input[name="status"]').attr('data');
            layui.admin.reloads({
                search_text:val1,
                datemin:val2.split(' ')[0],
                datemax:val2.split(' ')[2],
                type:type,
                status:status
            });
        });

    });
</script>
